<extend name="Base/common"/>

<block name="style">
<link href="__CSS__/stylesheet.css" rel="stylesheet">
<link href="__CSS__/user.css" rel="stylesheet">
</block>

<block name="header">
<header>
	<include file="User/header" />
</header>
</block>

<block name="body">
<div class="container main">
	<div class="user-main">
		<div class="col-xs-3">
			<include file="User/left_menu" />
		</div>
		<div class="col-xs-9">
			<h5>地址管理<a class="btn fr" href="{:U('receives')}">新增收货地址</a></h5>
			<div class="content col-xs-12">
				<form action="{:U('User/Editreceive')}" class="form-horizontal" enctype="multipart/form-data" autocomplete="off">
					<div class="form-group">
						<label class="label-control">收货人</label>
						<div class="input-control">
							<input type="text" name="realname"  class="form-control" value="{$info.realname}">
						</div>
					</div>
					<div class="form-group">
						<label class="label-control">所在地区</label>
						<div class="input-control">							
							<select class="form-control input-select" name="province_id" id="province">							
							<volist name=":getProvinces()" id="vo">
								<option value="{$vo.province_id}" <eq name="info.province_id" value="$vo.province_id">selected</eq>>{$vo.province}</option>
			     			</volist>
							</select>
						<script type="text/javascript">
			     		$(function(){
			     			$('#province').change(function(e){
			     				$('#city').html('<option value="">城市</option>');
			     				$('#area').html('<option value="">区县</option>');
			     				
			     				paramter = {format : 'json', province_id : $(this).val()};
			     				
			     				$.post('{:U('Api/Public/getCities')}', paramter, function(data){
			     					if (data.code == 1) {
			     						$.each(data.data, function(i, item){
			     							$('#city').append('<option value="' + item.city_id + '">' + item.city + '</option>');
			     						});
			     					}
			     				}, 'json');
			     			});
			     		});
			     		</script>
							<select class="form-control input-select" name="city_id" id=city>
							<volist name=":getCities($info['province_id'])" id="vo">
								<option value="{$vo.city_id}" <eq name="info.city_id" value="$vo.city_id">selected</eq>>{$vo.city}</option>
			     			</volist>							
							</select>
							<script type="text/javascript">
						     		$(function(){
						     			$('#city').change(function(e){
						     				$('#area').html('');			     				
						     				paramter = {format : 'json', city_id : $(this).val()};
						     				
						     				$.post('{:U('Api/Public/getAreas')}', paramter, function(data){
						     					$('#area').append('<option value="">区县</option>');
						     					if (data.code == 1) {
						     						$.each(data.data, function(i, item){
						     							$('#area').append('<option value="' + item.area_id + '">' + item.area + '</option>');
						     						});
						     					}
						     				}, 'json');
						     			});
						     		});
				     		</script>
							<select class="form-control input-select" name="area_id" id="area">
							<volist name=":getAreas($info['city_id'])" id="vo">
								<option value="{$vo.area_id}" <eq name="info.area_id" value="$vo.area_id">selected</eq>>{$vo.area}</option>
			     			</volist>													
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="label-control">详细地址</label>
						<div class="input-control">
							<input type="hidden" name="id" value="{$info.id}" />
							<input type="text" name="address" class="form-control" value="{$info.address}">
						</div>
					</div>
					<div class="form-group">
						<label class="label-control">手机号码</label>
						<div class="input-control">
							<input type="text" name="mobile" class="form-control" value="{$info.mobile}">
						</div>
					</div>
					<div class="form-group">
						<label class="label-control">设为默认</label>
						<div class="input-control">
							<label class="radio"><input type="radio" name="is_default" value="1" <eq name="info['is_default']" value="1">checked=checked</eq> >是</label>
							<label class="radio"><input type="radio" name="is_default" value="0" <eq name="info['is_default']" value="0">checked=checked</eq>>否</label>
						</div>
					</div>
					<div class="form-group">
						<div class="button-control" style="margin-top: 0px;">
							<a href="#" class="btn  ajax-post" target-form="form-horizontal" >保存</a>
						</div>
					</div>
				</form>
				<div class="receives-list">
					<p>您已经有7个收货地址，最多可以创建20个</p>
					<ul class="receives thead">
						<li>
							<ul class="table">
								<li>收货人</li>
								<li>收货地址</li>
								<li>详细地址</li>
								<li>手机号</li>
								<li>默认</li>
								<li>操作</li>
							</ul>
						</li>
					</ul>
					<ul class="receives tbody">
					<volist name="receive_list" id="vo" >
						<li>
							<ul class="table">
								<li>{$vo.realname}</li>
								<li>{$vo.address_full}</li>
								<li>{$vo.address}</li>
								<li>{$vo.mobile}</li>
								<li>
									<eq name="vo['is_default']" value="1">
									<span>默认地址</span>
									<else />
									<a  href="{:U('AjaxAction/receiveDefault?id='.$vo['id'])}" class="ajax-get">设为默认</a>
									</eq>
								</li>
								<li>
									<a href="{:U('receives',array('id'=>$vo['id']))}">编辑</a>
									<a href="{:U('Editreceive',array('id'=>$vo['id'],'method'=>'del'))}" class="ajax-get">删除</a>
								</li>
							</ul>
						</li>
					</volist>
					</ul>
				</div>
			</div>
		</div>
	</div>
</div>
</block>

<block name="script">
<script type="text/javascript">
highlight_leftnav("{:U('User/receives')}");
highlight_subnav("{:U('User/index')}");
</script>
</block>